package com.hust.service;

import com.hust.dao.PriceDao;
import com.hust.dao.PriceExample;
import com.hust.domain.Price;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class priceService {

    @Autowired
    private PriceDao priceDao;

    /**
    * @Description: 根据c_id查询最新的价格
    * @Param: [c_id]
    * @return: java.lang.String
    */
    public String getNewPrice(int c_id){
        PriceExample ce_price=new PriceExample();
        PriceExample.Criteria criteria_price = ce_price.createCriteria();
        criteria_price.andCIdIsNotNull();
        criteria_price.andCIdEqualTo((long)c_id);
        ce_price.setOrderByClause("c_date DESC");
        ce_price.setLimit(1);
        //根据cid查询
        List<Price> historyPrice = priceDao.selectByExample(ce_price);
        return historyPrice.get(0).getcPrice();
    }
}
